package com.aaa.controller;

import com.aaa.entity.LeadingUser;
import com.aaa.entity.State;
import com.aaa.service.LeadingUserService;
import com.aaa.service.StateService;
import com.aaa.util.DefaultMsg;
import com.aaa.util.TableData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/leadingUser")
public class LeadingUserController {
    @Autowired
    private LeadingUserService leadingUserService;
    @Autowired
    private StateService stateService;

    @RequestMapping("/toList")
    private String toList(){
        return "leadingUser/list";
    }
    @RequestMapping("/listData")
    @ResponseBody
    public TableData<LeadingUser>listData(@RequestParam(defaultValue = "")String keyword,Integer page,Integer limit){
        TableData<LeadingUser> tableData = leadingUserService.page(keyword, page, limit);
        return tableData;
    }
    @RequestMapping("/StatelistAll")
    @ResponseBody
    public List<State> StatelistAll(){
        List<State> states = stateService.listAll();
        return states;
    }
    @RequestMapping("/state")
    @ResponseBody
    public DefaultMsg state(LeadingUser leadingUser,Integer id){
        DefaultMsg state = leadingUserService.state(leadingUser, id);
        return state;
    }
}
